home *** CD-ROM | disk | FTP | other *** search
- Path: bnc.net!news
- From: Alexander.Glaeser@Bonn.Netsurf.De (Alex Glaeser)
- Newsgroups: comp.lang.c++
- Subject: Re: READING FROM A TEXTFILE
- Date: Sat, 13 Apr 1996 07:36:53 GMT
- Organization: Bonner Network Consulting
- Message-ID: <316f5587.1505339@news.bonn.netsurf.de>
- References: <Pine.SUN.3.90.960412122731.1477A-100000@dew.cs.odu.edu>
- NNTP-Posting-Host: angra.bonn.netsurf.de
- X-Newsreader: Forte Agent .99d/32.182
-
-
-
- Hi Cleveland !!
-
- > I have had trouble reading from a textfile. I am trying to read
- >a textfile into a C++ struct. This is the struct
- >
- >#include <iostream.h>
- >#include <fstream.h>
- >
- >
- > struct students {
- >char firstname[20];
- >char middle_initial;
- >char lastname[20];
- >char address1[40];
- >char address2[30];
- >char phone_number[7];
- >char email[50];
- >char dept[16];
- >char edu_level[9];
- >};
- >
- >
- >The textfile has contains char firstname down to edu_level --- each char
- >string is one line in the file.
- >
- >How can I read this struct from the textfile?
-
- You have to fill it up step by step.
- Just use the function called "filename.getline(*string[],positions)".
- In this case "filename" is the internal name of the file you want to
- read from. "*string[]" is the array you want to read in and
- "positions" is the maximum number of characters you want to read from
- this line. Getline() will return a reference to *string[].
-
- Hope this will help.
-
- Later
- ALEX
-
- __________________________________________________________________
- Think Positive !!! ## Phone'n'Fax ++49 2241 330773 ##
-